<html>
<head><meta charset="utf-8"><title>root package · t-cargo/PubGrub · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/260232-t-cargo/PubGrub/index.html">t-cargo/PubGrub</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/260232-t-cargo/PubGrub/topic/root.20package.html">root package</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="218687041"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260232-t-cargo/PubGrub/topic/root%20package/near/218687041" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> MrGreenTea <a href="https://rust-lang.github.io/zulip_archive/stream/260232-t-cargo/PubGrub/topic/root.20package.html#218687041">(Dec 03 2020 at 12:36)</a>:</h4>
<p>Hi, thanks for the great work!<br>
I am currently experimenting with the <code>pubgrub-rs</code> crate and hope to integrate it with <a href="http://pypi.org">pypi.org</a> and especially with <a href="https://python-poetry.org/"><code>poetry</code></a>.</p>
<p>Currently I am struggling with resolving dependencies for a package because I want to only look up packages that are not my root package on the remote.</p>
<p>For example let's say I have <code>root</code> at version <code>1.0.0</code> and that has not been released to <a href="http://pypi.org">pypi.org</a>.<br>
I don't want to look up <code>root</code> at <a href="http://pypi.org">pypi.org</a>, but all other packages.<br>
Because <code>choose_package_version</code> get's an <code>impl Iterator</code> I am currently struggling with that.<br>
What I tried to do is show if <code>(T, U) == ("root", _)</code>  and if so return <code>("root", 1.0.0)</code> but if it's not <code>root</code> i need to provide the iterator to my remote dependency provider. Even then I can't really get it to work.</p>
<p>This is the current implementation that does not work.</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">fn</span> <span class="nf">choose_package_version</span><span class="o">&lt;</span><span class="n">T</span>: <span class="nc">Borrow</span><span class="o">&lt;</span><span class="nb">String</span><span class="o">&gt;</span><span class="p">,</span><span class="w"> </span><span class="n">U</span>: <span class="nc">Borrow</span><span class="o">&lt;</span><span class="n">Range</span><span class="o">&lt;</span><span class="n">PEP440Version</span><span class="o">&gt;&gt;&gt;</span><span class="p">(</span><span class="w"></span>
<span class="w">        </span><span class="o">&amp;</span><span class="bp">self</span><span class="p">,</span><span class="w"></span>
<span class="w">        </span><span class="n">potential_packages</span>: <span class="nc">impl</span><span class="w"> </span><span class="nb">Iterator</span><span class="o">&lt;</span><span class="n">Item</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">(</span><span class="n">T</span><span class="p">,</span><span class="w"> </span><span class="n">U</span><span class="p">)</span><span class="o">&gt;</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nb">Result</span><span class="o">&lt;</span><span class="p">(</span><span class="n">T</span><span class="p">,</span><span class="w"> </span><span class="nb">Option</span><span class="o">&lt;</span><span class="n">PEP440Version</span><span class="o">&gt;</span><span class="p">),</span><span class="w"> </span><span class="nb">Box</span><span class="o">&lt;</span><span class="k">dyn</span><span class="w"> </span><span class="n">Error</span><span class="o">&gt;&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="kd">let</span><span class="w"> </span><span class="n">vec</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">potential_packages</span><span class="p">.</span><span class="n">collect</span><span class="p">();</span><span class="w"></span>
<span class="w">        </span><span class="k">match</span><span class="w"> </span><span class="n">vec</span><span class="p">.</span><span class="n">iter</span><span class="p">().</span><span class="n">find</span><span class="p">(</span><span class="o">|</span><span class="p">(</span><span class="n">p</span><span class="p">,</span><span class="w"> </span><span class="n">_</span><span class="p">)</span><span class="o">|</span><span class="w"> </span><span class="n">p</span><span class="p">.</span><span class="n">borrow</span><span class="p">()</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="o">&amp;</span><span class="bp">self</span><span class="p">.</span><span class="n">root</span><span class="p">.</span><span class="n">package</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">            </span><span class="nb">Some</span><span class="p">((</span><span class="n">p</span><span class="p">,</span><span class="w"> </span><span class="n">_</span><span class="p">))</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">                </span><span class="nb">Ok</span><span class="p">(</span><span class="w"></span>
<span class="w">                    </span><span class="p">(</span><span class="n">p</span><span class="p">,</span><span class="w"> </span><span class="nb">Some</span><span class="p">(</span><span class="bp">self</span><span class="p">.</span><span class="n">root</span><span class="p">.</span><span class="n">version</span><span class="p">.</span><span class="n">clone</span><span class="p">()))</span><span class="w"></span>
<span class="w">                </span><span class="p">)</span><span class="w"></span>
<span class="w">            </span><span class="p">}</span><span class="w"></span>
<span class="w">            </span><span class="nb">None</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="bp">self</span><span class="p">.</span><span class="n">remote</span><span class="p">.</span><span class="n">choose_package_version</span><span class="p">(</span><span class="n">vec</span><span class="p">.</span><span class="n">iter</span><span class="p">())</span><span class="w"></span>
<span class="w">        </span><span class="p">}</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
</code></pre></div>
<p>Would appreciate any and every help :)</p>



<a name="218692502"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260232-t-cargo/PubGrub/topic/root%20package/near/218692502" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthieu Pizenberg <a href="https://rust-lang.github.io/zulip_archive/stream/260232-t-cargo/PubGrub/topic/root.20package.html#218692502">(Dec 03 2020 at 13:31)</a>:</h4>
<p>Hi <span class="user-mention" data-user-id="367935">@MrGreenTea</span> , welcome! If I get the problem right, you are interested in an example of dealing with dependencies of a <strong>project</strong> being worked on instead of dependencies of an already published <strong>package</strong>.<br>
Your code logic seems fine, is the issue a compilation issue?<br>
Do you have a repository we could clone to test things?</p>
<p>PS: I'm currently working on integrating pubgrub-rs into a dependency provider for elm projects so I'll have exactly the same problematic soon and will be able to share a more complete example use case. But that may take few weeks.</p>



<a name="218692809"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260232-t-cargo/PubGrub/topic/root%20package/near/218692809" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthieu Pizenberg <a href="https://rust-lang.github.io/zulip_archive/stream/260232-t-cargo/PubGrub/topic/root.20package.html#218692809">(Dec 03 2020 at 13:35)</a>:</h4>
<p>By the way, the landing page for poetry is magnificent :) and I very much appreciate improvements in managing python packages ^^</p>



<a name="218695009"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260232-t-cargo/PubGrub/topic/root%20package/near/218695009" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthieu Pizenberg <a href="https://rust-lang.github.io/zulip_archive/stream/260232-t-cargo/PubGrub/topic/root.20package.html#218695009">(Dec 03 2020 at 13:55)</a>:</h4>
<p>Just a heads up, looking at the <a href="https://python-poetry.org/docs/dependency-specification/">dependency specifications of poetry</a>, it seems like you have a lot of features for which pubgrub is not ready yet. Things like environment markers, multiple constraints, pre-releases are currently in an exploratory phase: <a href="https://github.com/pubgrub-rs/advanced_dependency_providers/issues">https://github.com/pubgrub-rs/advanced_dependency_providers/issues</a></p>



<a name="218696622"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260232-t-cargo/PubGrub/topic/root%20package/near/218696622" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eh2406 <a href="https://rust-lang.github.io/zulip_archive/stream/260232-t-cargo/PubGrub/topic/root.20package.html#218696622">(Dec 03 2020 at 14:06)</a>:</h4>
<p>To be clear we would love help figuring out how to get them to work, but we don't have an answer to point you to.</p>



<a name="218696841"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260232-t-cargo/PubGrub/topic/root%20package/near/218696841" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eh2406 <a href="https://rust-lang.github.io/zulip_archive/stream/260232-t-cargo/PubGrub/topic/root.20package.html#218696841">(Dec 03 2020 at 14:08)</a>:</h4>
<p>for the <code>root</code> problem we can collect into a vector.</p>



<a name="218697206"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260232-t-cargo/PubGrub/topic/root%20package/near/218697206" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthieu Pizenberg <a href="https://rust-lang.github.io/zulip_archive/stream/260232-t-cargo/PubGrub/topic/root.20package.html#218697206">(Dec 03 2020 at 14:11)</a>:</h4>
<p>indeed, maybe doing <code>vec: Vec&lt;_&gt; = potential_packages.collect();</code> will help. Then in the <code>None</code> case use <code>vec.into_iter()</code>.</p>



<a name="218711084"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260232-t-cargo/PubGrub/topic/root%20package/near/218711084" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> MrGreenTea <a href="https://rust-lang.github.io/zulip_archive/stream/260232-t-cargo/PubGrub/topic/root.20package.html#218711084">(Dec 03 2020 at 15:40)</a>:</h4>
<p>That's exactly right, I want to resolve packages of the project being worked on.</p>



<a name="218711260"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260232-t-cargo/PubGrub/topic/root%20package/near/218711260" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> MrGreenTea <a href="https://rust-lang.github.io/zulip_archive/stream/260232-t-cargo/PubGrub/topic/root.20package.html#218711260">(Dec 03 2020 at 15:41)</a>:</h4>
<p>That pubgrub-rs might not support everything is totally okay, we're in the experimental phase too and kinda new to rust as well :)<br>
I hope to contribute to these things soon if possible.</p>
<p>I will share the repository tomorrow with the current experiments.</p>



<a name="218711403"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260232-t-cargo/PubGrub/topic/root%20package/near/218711403" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> MrGreenTea <a href="https://rust-lang.github.io/zulip_archive/stream/260232-t-cargo/PubGrub/topic/root.20package.html#218711403">(Dec 03 2020 at 15:42)</a>:</h4>
<p>I tried collecting into a vector but ran into borrow checker issues I could not resolve yet. I hoped perhaps someone here had a simple solution to this already. Thanks for the quick reply!</p>



<a name="218711554"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260232-t-cargo/PubGrub/topic/root%20package/near/218711554" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> MrGreenTea <a href="https://rust-lang.github.io/zulip_archive/stream/260232-t-cargo/PubGrub/topic/root.20package.html#218711554">(Dec 03 2020 at 15:43)</a>:</h4>
<p>If you ever work in python you really should use <code>poetry</code>, it's a joy to work with and we use it for all our python projects. I'm not affiliated with them (yet ;) ) though, this is something I'm doing with a colleague for now.</p>



<a name="218711711"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260232-t-cargo/PubGrub/topic/root%20package/near/218711711" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthieu Pizenberg <a href="https://rust-lang.github.io/zulip_archive/stream/260232-t-cargo/PubGrub/topic/root.20package.html#218711711">(Dec 03 2020 at 15:44)</a>:</h4>
<blockquote>
<p>I hoped perhaps someone here had a simple solution to this already. Thanks for the quick reply!</p>
</blockquote>
<p>I'll try to prioritize the things I have to do in that elm dependency provider in order to get as soon as possible to an example related to your use case now that I now that, but might still take some time ^^</p>



<a name="218713126"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260232-t-cargo/PubGrub/topic/root%20package/near/218713126" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eh2406 <a href="https://rust-lang.github.io/zulip_archive/stream/260232-t-cargo/PubGrub/topic/root.20package.html#218713126">(Dec 03 2020 at 15:54)</a>:</h4>
<p>When the code can be shared, I will be happy to look at the borrow checker issues. They are particularly narly to diagnose without looking at the code.</p>



<a name="218888726"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260232-t-cargo/PubGrub/topic/root%20package/near/218888726" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> MrGreenTea <a href="https://rust-lang.github.io/zulip_archive/stream/260232-t-cargo/PubGrub/topic/root.20package.html#218888726">(Dec 04 2020 at 20:43)</a>:</h4>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">fn</span> <span class="nf">choose_package_version</span><span class="o">&lt;</span><span class="n">T</span>: <span class="nc">Borrow</span><span class="o">&lt;</span><span class="nb">String</span><span class="o">&gt;</span><span class="p">,</span><span class="w"> </span><span class="n">U</span>: <span class="nc">Borrow</span><span class="o">&lt;</span><span class="n">Range</span><span class="o">&lt;</span><span class="n">PEP440Version</span><span class="o">&gt;&gt;&gt;</span><span class="p">(</span><span class="w"></span>
<span class="w">        </span><span class="o">&amp;</span><span class="bp">self</span><span class="p">,</span><span class="w"></span>
<span class="w">        </span><span class="n">potential_packages</span>: <span class="nc">impl</span><span class="w"> </span><span class="nb">Iterator</span><span class="o">&lt;</span><span class="n">Item</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">(</span><span class="n">T</span><span class="p">,</span><span class="w"> </span><span class="n">U</span><span class="p">)</span><span class="o">&gt;</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nb">Result</span><span class="o">&lt;</span><span class="p">(</span><span class="n">T</span><span class="p">,</span><span class="w"> </span><span class="nb">Option</span><span class="o">&lt;</span><span class="n">PEP440Version</span><span class="o">&gt;</span><span class="p">),</span><span class="w"> </span><span class="nb">Box</span><span class="o">&lt;</span><span class="k">dyn</span><span class="w"> </span><span class="n">Error</span><span class="o">&gt;&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="kd">let</span><span class="w"> </span><span class="n">vec</span>: <span class="nb">Vec</span><span class="o">&lt;</span><span class="p">(</span><span class="n">T</span><span class="p">,</span><span class="w"> </span><span class="n">U</span><span class="p">)</span><span class="o">&gt;</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">potential_packages</span><span class="p">.</span><span class="n">collect</span><span class="p">();</span><span class="w"></span>
<span class="w">        </span><span class="k">match</span><span class="w"> </span><span class="n">vec</span><span class="p">.</span><span class="n">iter</span><span class="p">().</span><span class="n">find</span><span class="p">(</span><span class="o">|</span><span class="p">(</span><span class="n">p</span><span class="p">,</span><span class="w"> </span><span class="n">_</span><span class="p">)</span><span class="o">|</span><span class="w"> </span><span class="n">p</span><span class="p">.</span><span class="n">borrow</span><span class="p">()</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="o">&amp;</span><span class="bp">self</span><span class="p">.</span><span class="n">root</span><span class="p">.</span><span class="n">package</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">            </span><span class="nb">Some</span><span class="p">((</span><span class="n">p</span><span class="p">,</span><span class="w"> </span><span class="n">_</span><span class="p">))</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">                </span><span class="nb">Ok</span><span class="p">(</span><span class="w"></span>
<span class="w">                    </span><span class="p">(</span><span class="n">p</span><span class="p">,</span><span class="w"> </span><span class="nb">Some</span><span class="p">(</span><span class="bp">self</span><span class="p">.</span><span class="n">root</span><span class="p">.</span><span class="n">version</span><span class="p">.</span><span class="n">clone</span><span class="p">()))</span><span class="w"></span>
<span class="w">                </span><span class="p">)</span><span class="w"></span>
<span class="w">            </span><span class="p">}</span><span class="w"></span>
<span class="w">            </span><span class="nb">None</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="bp">self</span><span class="p">.</span><span class="n">remote</span><span class="p">.</span><span class="n">choose_package_version</span><span class="p">(</span><span class="n">vec</span><span class="p">.</span><span class="n">into_iter</span><span class="p">())</span><span class="w"></span>
<span class="w">        </span><span class="p">}</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
</code></pre></div>
<p>This is the part I am struggling with.<br>
I am actually unsure if it's the borrow checker or something else I am clueless about here.<br>
In the <code>Some((p, _))</code> case <code>p: &amp;T</code> but I need <code>T</code> and can't move it.<br>
This is the error I get:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="n">error</span><span class="p">[</span><span class="n">E0308</span><span class="p">]</span>: <span class="nc">mismatched</span><span class="w"> </span><span class="n">types</span><span class="w"></span>
<span class="w">  </span><span class="o">-</span>-&gt; <span class="nc">src</span><span class="o">/</span><span class="n">poetry_provider</span><span class="p">.</span><span class="n">rs</span>:<span class="mi">41</span>:<span class="mi">22</span><span class="w"></span>
<span class="w">   </span><span class="o">|</span><span class="w"></span>
<span class="mi">33</span><span class="w"> </span><span class="o">|</span><span class="w">     </span><span class="k">fn</span> <span class="nf">choose_package_version</span><span class="o">&lt;</span><span class="n">T</span>: <span class="nc">Borrow</span><span class="o">&lt;</span><span class="nb">String</span><span class="o">&gt;</span><span class="p">,</span><span class="w"> </span><span class="n">U</span>: <span class="nc">Borrow</span><span class="o">&lt;</span><span class="n">Range</span><span class="o">&lt;</span><span class="n">PEP440Version</span><span class="o">&gt;&gt;&gt;</span><span class="p">(</span><span class="w"></span>
<span class="w">   </span><span class="o">|</span><span class="w">                               </span><span class="o">-</span><span class="w"> </span><span class="n">this</span><span class="w"> </span><span class="k">type</span> <span class="nc">parameter</span><span class="w"></span>
<span class="o">..</span><span class="p">.</span><span class="w"></span>
<span class="mi">41</span><span class="w"> </span><span class="o">|</span><span class="w">                     </span><span class="p">(</span><span class="n">p</span><span class="p">,</span><span class="w"> </span><span class="nb">Some</span><span class="p">(</span><span class="bp">self</span><span class="p">.</span><span class="n">root</span><span class="p">.</span><span class="n">version</span><span class="p">.</span><span class="n">clone</span><span class="p">()))</span><span class="w"></span>
<span class="w">   </span><span class="o">|</span><span class="w">                      </span><span class="o">^</span><span class="w"> </span><span class="n">expected</span><span class="w"> </span><span class="k">type</span> <span class="nc">parameter</span><span class="w"> </span><span class="err">`</span><span class="n">T</span><span class="err">`</span><span class="p">,</span><span class="w"> </span><span class="n">found</span><span class="w"> </span><span class="err">`</span><span class="o">&amp;</span><span class="n">T</span><span class="err">`</span><span class="w"></span>
<span class="w">   </span><span class="o">|</span><span class="w"></span>
<span class="w">   </span><span class="o">=</span><span class="w"> </span><span class="n">note</span>: <span class="nc">expected</span><span class="w"> </span><span class="k">type</span> <span class="nc">parameter</span><span class="w"> </span><span class="err">`</span><span class="n">T</span><span class="err">`</span><span class="w"></span>
<span class="w">                   </span><span class="n">found</span><span class="w"> </span><span class="n">reference</span><span class="w"> </span><span class="err">`</span><span class="o">&amp;</span><span class="n">T</span><span class="err">`</span><span class="w"></span>
</code></pre></div>



<a name="218888853"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260232-t-cargo/PubGrub/topic/root%20package/near/218888853" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> MrGreenTea <a href="https://rust-lang.github.io/zulip_archive/stream/260232-t-cargo/PubGrub/topic/root.20package.html#218888853">(Dec 04 2020 at 20:44)</a>:</h4>
<p>I don't feel comfortable making the repo public yet, but if you send me your github username I'll add you if you are interested to see the current experiments ;)</p>



<a name="218889076"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260232-t-cargo/PubGrub/topic/root%20package/near/218889076" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eh2406 <a href="https://rust-lang.github.io/zulip_archive/stream/260232-t-cargo/PubGrub/topic/root.20package.html#218889076">(Dec 04 2020 at 20:46)</a>:</h4>
<p>I am Eh2406 on github, and I am very interested!</p>



<a name="218889194"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260232-t-cargo/PubGrub/topic/root%20package/near/218889194" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eh2406 <a href="https://rust-lang.github.io/zulip_archive/stream/260232-t-cargo/PubGrub/topic/root.20package.html#218889194">(Dec 04 2020 at 20:47)</a>:</h4>
<p>I would like to try to get things to work with the api we have, but it may be that for 0.3 the api may need to be more flexible.</p>



<a name="218889451"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260232-t-cargo/PubGrub/topic/root%20package/near/218889451" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> MrGreenTea <a href="https://rust-lang.github.io/zulip_archive/stream/260232-t-cargo/PubGrub/topic/root.20package.html#218889451">(Dec 04 2020 at 20:50)</a>:</h4>
<p>I've sent you an invite</p>



<a name="218891941"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260232-t-cargo/PubGrub/topic/root%20package/near/218891941" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eh2406 <a href="https://rust-lang.github.io/zulip_archive/stream/260232-t-cargo/PubGrub/topic/root.20package.html#218891941">(Dec 04 2020 at 21:12)</a>:</h4>
<p>I am getting  Error: "Python 3.x interpreter not found" I think I need to set a <code>PYO3_PYTHON</code> but I don't know to what.</p>



<a name="218892145"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260232-t-cargo/PubGrub/topic/root%20package/near/218892145" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> MrGreenTea <a href="https://rust-lang.github.io/zulip_archive/stream/260232-t-cargo/PubGrub/topic/root.20package.html#218892145">(Dec 04 2020 at 21:14)</a>:</h4>
<p>Hm weird, I did not have to do that. I assume set it to the path of your <code>python3</code> binary?</p>



<a name="218892463"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260232-t-cargo/PubGrub/topic/root%20package/near/218892463" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eh2406 <a href="https://rust-lang.github.io/zulip_archive/stream/260232-t-cargo/PubGrub/topic/root.20package.html#218892463">(Dec 04 2020 at 21:18)</a>:</h4>
<p>With some tinkering I got it to work. That is what I get for having multiple pythons installed.</p>



<a name="218893040"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260232-t-cargo/PubGrub/topic/root%20package/near/218893040" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eh2406 <a href="https://rust-lang.github.io/zulip_archive/stream/260232-t-cargo/PubGrub/topic/root.20package.html#218893040">(Dec 04 2020 at 21:24)</a>:</h4>
<p><a href="https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.partition">https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.partition</a><br>
may be a way to get this to work.</p>



<a name="218893775"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260232-t-cargo/PubGrub/topic/root%20package/near/218893775" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> MrGreenTea <a href="https://rust-lang.github.io/zulip_archive/stream/260232-t-cargo/PubGrub/topic/root.20package.html#218893775">(Dec 04 2020 at 21:32)</a>:</h4>
<p>He cool yeah I got it working with that:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="kd">let</span><span class="w"> </span><span class="p">(</span><span class="n">root</span><span class="p">,</span><span class="w"> </span><span class="n">other</span><span class="p">)</span>: <span class="p">(</span><span class="nb">Vec</span><span class="o">&lt;</span><span class="n">_</span><span class="o">&gt;</span><span class="p">,</span><span class="w"> </span><span class="nb">Vec</span><span class="o">&lt;</span><span class="n">_</span><span class="o">&gt;</span><span class="p">)</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">potential_packages</span><span class="p">.</span><span class="n">partition</span><span class="p">(</span><span class="o">|</span><span class="p">(</span><span class="n">p</span><span class="p">,</span><span class="w"> </span><span class="n">_</span><span class="p">)</span><span class="o">|</span><span class="w"> </span><span class="n">p</span><span class="p">.</span><span class="n">borrow</span><span class="p">()</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="o">&amp;</span><span class="bp">self</span><span class="p">.</span><span class="n">root</span><span class="p">.</span><span class="n">package</span><span class="p">);</span><span class="w"></span>
<span class="k">match</span><span class="w"> </span><span class="n">root</span><span class="p">.</span><span class="n">into_iter</span><span class="p">().</span><span class="n">next</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="nb">Some</span><span class="p">((</span><span class="n">p</span><span class="p">,</span><span class="w"> </span><span class="n">_</span><span class="p">))</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="nb">Ok</span><span class="p">((</span><span class="n">p</span><span class="p">,</span><span class="w"> </span><span class="nb">Some</span><span class="p">(</span><span class="bp">self</span><span class="p">.</span><span class="n">root</span><span class="p">.</span><span class="n">version</span><span class="p">.</span><span class="n">clone</span><span class="p">()))),</span><span class="w"></span>
<span class="w">    </span><span class="nb">None</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="bp">self</span><span class="p">.</span><span class="n">remote</span><span class="p">.</span><span class="n">choose_package_version</span><span class="p">(</span><span class="n">other</span><span class="p">.</span><span class="n">into_iter</span><span class="p">())</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="218894068"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260232-t-cargo/PubGrub/topic/root%20package/near/218894068" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eh2406 <a href="https://rust-lang.github.io/zulip_archive/stream/260232-t-cargo/PubGrub/topic/root.20package.html#218894068">(Dec 04 2020 at 21:34)</a>:</h4>
<p>If the allocations are in the profile, we can optimize with filter map. But we got something working.</p>



<a name="218895153"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260232-t-cargo/PubGrub/topic/root%20package/near/218895153" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eh2406 <a href="https://rust-lang.github.io/zulip_archive/stream/260232-t-cargo/PubGrub/topic/root.20package.html#218895153">(Dec 04 2020 at 21:45)</a>:</h4>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="w">        </span><span class="kd">let</span><span class="w"> </span><span class="k">mut</span><span class="w"> </span><span class="n">root</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">None</span><span class="p">;</span><span class="w"></span>
<span class="w">        </span><span class="kd">let</span><span class="w"> </span><span class="n">other</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="bp">self</span><span class="w"></span>
<span class="w">            </span><span class="p">.</span><span class="n">remote</span><span class="w"></span>
<span class="w">            </span><span class="p">.</span><span class="n">choose_package_version</span><span class="p">(</span><span class="n">potential_packages</span><span class="p">.</span><span class="n">filter_map</span><span class="p">(</span><span class="o">|</span><span class="p">(</span><span class="n">t</span><span class="p">,</span><span class="w"> </span><span class="n">u</span><span class="p">)</span><span class="o">|</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">                </span><span class="k">if</span><span class="w"> </span><span class="n">t</span><span class="p">.</span><span class="n">borrow</span><span class="p">()</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="o">&amp;</span><span class="bp">self</span><span class="p">.</span><span class="n">root</span><span class="p">.</span><span class="n">package</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">                    </span><span class="n">root</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">Some</span><span class="p">((</span><span class="n">t</span><span class="p">,</span><span class="w"> </span><span class="nb">Some</span><span class="p">(</span><span class="bp">self</span><span class="p">.</span><span class="n">root</span><span class="p">.</span><span class="n">version</span><span class="p">.</span><span class="n">clone</span><span class="p">())));</span><span class="w"></span>
<span class="w">                    </span><span class="nb">None</span><span class="w"></span>
<span class="w">                </span><span class="p">}</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">                    </span><span class="nb">Some</span><span class="p">((</span><span class="n">t</span><span class="p">,</span><span class="w"> </span><span class="n">u</span><span class="p">))</span><span class="w"></span>
<span class="w">                </span><span class="p">}</span><span class="w"></span>
<span class="w">            </span><span class="p">}));</span><span class="w"></span>
<span class="w">        </span><span class="k">if</span><span class="w"> </span><span class="kd">let</span><span class="w"> </span><span class="nb">Some</span><span class="p">(</span><span class="n">root</span><span class="p">)</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">root</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">            </span><span class="nb">Ok</span><span class="p">(</span><span class="n">root</span><span class="p">)</span><span class="w"></span>
<span class="w">        </span><span class="p">}</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">            </span><span class="n">other</span><span class="w"></span>
<span class="w">        </span><span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="218896007"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260232-t-cargo/PubGrub/topic/root%20package/near/218896007" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eh2406 <a href="https://rust-lang.github.io/zulip_archive/stream/260232-t-cargo/PubGrub/topic/root.20package.html#218896007">(Dec 04 2020 at 21:54)</a>:</h4>
<p>But let's stick with the 5 line version until we need to make things more complicated.</p>



<a name="218899921"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260232-t-cargo/PubGrub/topic/root%20package/near/218899921" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> MrGreenTea <a href="https://rust-lang.github.io/zulip_archive/stream/260232-t-cargo/PubGrub/topic/root.20package.html#218899921">(Dec 04 2020 at 22:35)</a>:</h4>
<p>I agree, it works for now on the rust side, thanks a lot!<br>
I'll have to do some work on the python side now to integrate the solution correctly.</p>



<a name="218900403"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260232-t-cargo/PubGrub/topic/root%20package/near/218900403" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> MrGreenTea <a href="https://rust-lang.github.io/zulip_archive/stream/260232-t-cargo/PubGrub/topic/root.20package.html#218900403">(Dec 04 2020 at 22:40)</a>:</h4>
<p>I think we'll rewrite this entirely after we're over this initial exploratory phase.</p>



<a name="218909703"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260232-t-cargo/PubGrub/topic/root%20package/near/218909703" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eh2406 <a href="https://rust-lang.github.io/zulip_archive/stream/260232-t-cargo/PubGrub/topic/root.20package.html#218909703">(Dec 05 2020 at 01:02)</a>:</h4>
<p>The way I am reading the code, this may also be a good place to try and work on <a href="https://github.com/pubgrub-rs/advanced_dependency_providers/issues/6">https://github.com/pubgrub-rs/advanced_dependency_providers/issues/6</a> when we have full examples that can be tested.</p>



<a name="218926574"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260232-t-cargo/PubGrub/topic/root%20package/near/218926574" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> MrGreenTea <a href="https://rust-lang.github.io/zulip_archive/stream/260232-t-cargo/PubGrub/topic/root.20package.html#218926574">(Dec 05 2020 at 09:04)</a>:</h4>
<p>What place exactly do you think would benefit from async? The <code>reqwest</code> calls?</p>



<a name="218935540"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260232-t-cargo/PubGrub/topic/root%20package/near/218935540" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eh2406 <a href="https://rust-lang.github.io/zulip_archive/stream/260232-t-cargo/PubGrub/topic/root.20package.html#218935540">(Dec 05 2020 at 13:36)</a>:</h4>
<p>Yes, in theory it can be requesting meny deps in parallel.</p>



<a name="218935963"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260232-t-cargo/PubGrub/topic/root%20package/near/218935963" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthieu Pizenberg <a href="https://rust-lang.github.io/zulip_archive/stream/260232-t-cargo/PubGrub/topic/root.20package.html#218935963">(Dec 05 2020 at 13:49)</a>:</h4>
<p>I haven't read <span class="user-mention" data-user-id="367935">@MrGreenTea</span> code, but from pubgrub point of view, only <code>choose_package_version</code> has an opportunity of parallelism/concurency. The <code>get_dependencies</code> method will only be called one at a time when evaluating a chosen package. So depending on the registry architecture and API, it may have an opportunity for parallelism or not in <code>choose_package_version</code>. For example in Elm, there is no API to ask for existing versions of only one package. We can only ask for all existing versions (without their dependencies) or all recent versions (again without their dependencies). So only one network request is made in <code>choose_package_version</code> (actually 0 request since its better to do that request once before solving) and there is no opportunity to do parallel things with elm packages.</p>



<a name="218936315"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260232-t-cargo/PubGrub/topic/root%20package/near/218936315" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eh2406 <a href="https://rust-lang.github.io/zulip_archive/stream/260232-t-cargo/PubGrub/topic/root.20package.html#218936315">(Dec 05 2020 at 13:59)</a>:</h4>
<p>You are correct. I ment requesting the versions of many packages in parallel.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>